package ma.ensao.egicom.core.model;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.scub.foundation.framework.core.model.BaseModel;

@Entity
@Table(name = "marketorderline", schema = "public")
public class Marketorderline extends BaseModel {

    private MarketorderlineId compositeId;

    private Product product;

    private Marketorder marketorder;

    private Integer quantity;

    public Marketorderline() {
    }

    public Marketorderline(MarketorderlineId id, Product product, Marketorder marketorder) {
        this.compositeId = id;
        this.product = product;
        this.marketorder = marketorder;
    }

    public Marketorderline(MarketorderlineId id, Product product, Marketorder marketorder, Integer quantity) {
        this.compositeId = id;
        this.product = product;
        this.marketorder = marketorder;
        this.quantity = quantity;
    }

    @EmbeddedId
    @AttributeOverrides({@AttributeOverride(name = "marketorderlineid", column = @Column(name = "marketorderlineid", nullable = false)),
        @AttributeOverride(name = "marketorderid", column = @Column(name = "marketorderid", nullable = false)),
        @AttributeOverride(name = "productid", column = @Column(name = "productid", nullable = false))})
    public MarketorderlineId getCompositeId() {
        return this.compositeId;
    }

    public void setCompositeId(MarketorderlineId compositeId) {
        this.compositeId = compositeId;
    }

    public void setId(MarketorderlineId id) {
        this.compositeId = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "productid", nullable = false, insertable = false, updatable = false)
    public Product getProduct() {
        return this.product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "marketorderid", nullable = false, insertable = false, updatable = false)
    public Marketorder getMarketorder() {
        return this.marketorder;
    }

    public void setMarketorder(Marketorder marketorder) {
        this.marketorder = marketorder;
    }

    @Column(name = "quantity")
    public Integer getQuantity() {
        return this.quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    @Override
    public boolean equals(Object other) {
        // TODO Auto-generated method stub
        return false;
    }

}
